<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>作业一</title>
</head>
<body>
<script>
    //计算最大公约数
    var a = 64;
    var b = 56;
    var max;//最大公约数
    for (var i = 1; i <= a; i++) {
        if (a % i === 0 && b % i === 0) {
            max = i;
        }
    }
    console.log("最大公约数为" + max)

    //计算最小公倍数
    var max = a > b ? a : b;
    for (let j = max; ; j++) {
        if (j % a === 0 && j % b === 0) {
            console.log("最小公倍数为" + j);
            break;
        }
    }
    //计算阶层和
    var sum = 0;

    for (var m = 1; m <= 10; m++) {
        var num1 = 1;
        for (var n = 1; n <= m; n++) {
            num1 *= n;
        }
        sum += num1;
    }
    console.log("10以内的阶层和为" + sum)

    //给出一个年分月份，指出改年有多少天。
    //分析逻辑，判断闰年非闰年 ，利用switch case的贯穿特性
    var year = 2020;
    var month = 2;
    switch (month) {
        case 1, 3, 5, 7, 8, 10, 12:
            console.log(year + "年" + month + "月" + "有" + 31 + "天");
            break
        case 2:
            if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) {
                console.log(year + "年" + month + "月" + "有" + 29 + "天");
            } else {
                console.log(year + "年" + month + "月" + "有" + 28 + "天");
            }
            break
        default:
            console.log(year + "年" + month + "月" + "有" + 30 + "天");
    }
</script>
</body>
</html>